--[[
-- added by wsh @ 2017-12-05
-- 单例类
--]]

local Singleton = BaseClass();

function Singleton: __init()
	--assert(rawget(self._class_type, "Instance") == nil, self._class_type.__cname.." to create singleton twice!")
	rawset(self._class_type, "Instance", self)
end

function Singleton: __delete()
	rawset(self._class_type, "Instance", nil)
end

-- 只是用于启动模块
function Singleton: Startup()
end

-- 不要重写
function Singleton:GetInstance()
	if rawget(self, "Instance") == nil then
		rawset(self, "Instance", self.New())
	end
	assert(self.Instance ~= nil)
	return self.Instance
end

-- 不要重写
 function Singleton:Delete()
	self.Instance = nil
end

return Singleton;
